#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define int long long
#define pb push_back
#define MOD 1000000007
int bigmod (int b, int p){
if (p==0) return 1LL;
if (p==1) return b%MOD;
int cur=bigmod(b, p/2);
cur=(cur*cur)%MOD;
if (p%2==0) return cur;
else return (b*cur)%MOD;
}
void solve(){
int n, k;
cin>>n>>k;
n--;
int cur=n;
int ans=0;
for (int i=1; i<=k; i++){
if (cur<1) break;
ans+=cur+cur-1;
cur-=2;
}
cout<<ans<<endl;
}
signed main(){
int t;
t=1;
while (t--) solve();
}
1462A - Favorite Sequence | 1445B - Elimination |
1656C - Make Equal With Mod | 567A - Lineland Mail |
1553A - Digits Sum | 1359B - New Theatre Square |
766A - Mahmoud and Longest Uncommon Subsequence | 701B - Cells Not Under Attack |
702A - Maximum Increase | 1656D - K-good |
1426A - Floor Number | 876A - Trip For Meal |
1326B - Maximums | 1635C - Differential Sorting |
961A - Tetris | 1635B - Avoid Local Maximums |
20A - BerOS file system | 1637A - Sorting Parts |
509A - Maximum in Table | 1647C - Madoka and Childish Pranks |
689B - Mike and Shortcuts | 379B - New Year Present |
1498A - GCD Sum | 1277C - As Simple as One and Two |
1301A - Three Strings | 460A - Vasya and Socks |
1624C - Division by Two and Permutation | 1288A - Deadline |
1617A - Forbidden Subsequence | 914A - Perfect Squares |